{% extends 'Log_base.html' %}

{% block title %}Log in|Blog{% endblock %}

{% block css %} {% endblock %}
{% block script %}
	$("#signup_forms_submit").click(function(){
		var sUsername = $("#signup_email").val();
		var sPassword = $("#signup_password").val();
		if($("#signup_email").val()==""||$("#signup_password").val()=="")
		{
			$('<p>Notify:Username or Password is empty!</p>').notify();
		}
		else
		{
			$.post("/server/login",
			{
			  username:sUsername,
			  password:sPassword
			},
			function(data,status){
				if(null == data)
				{
					alert("return null");
					return;
				}
				
				if("0" == data.code)
				{
					$(window.location).attr("href", "/client/welcome");
				}
				else
				{
					var type = "notify";
					if("3" == data.code)
					{
						type = "notify";
					}
					else if("2" == data.code)
					{
						type = "warning";
					}
					else if("1" == data.code)
					{
						type = "error";
					}
					else if("0" == data.code)
					{
						type = "success";
					}
					else
					{
						type = "error";
					}
					$("<p>" + data.msg + "</p>").notify(type);
				}
			});
		}
	});
	$("#signup_forms_register").click(function(){
		$(window.location).attr("href", "/client/register");
	});
{% endblock %}

{% block content %}
	<div class="form_header">
		<h2 id="logo">Blog</h2>
		<h2 id="subheading">To explore and discover</h2>
	</div>
	<div class="signup_forms">
		<div id="signup_forms_container" class="signup_forms_container">
				<form class="signup_form_form" id="sign_form">
					<div class="signup_account" id="signup_account">
						<div class="form_user">
							<input type="text" name="email" placeholder="Email" id="signup_email">
						</div>
						<div class="form_password">
							<input type="password" name="password" placeholder="Password" id="signup_password">
						</div>
					</div>
				</form>
		</div>
		<button type="button" id="signup_forms_submit"><span><strong>Log in</strong></span></button>
		<button type="button" id="signup_forms_register"><span><strong>Register</strong></span></button>
	</div>
{% endblock %}

{% block signup %}
<a class="signup_link" id="sign_up" href="/client/register">Sign up</a>
{% endblock %}